import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
  Query,
} from '@nestjs/common';
import { FavService } from '../service/fav.service';
import { CreateFavDto } from '../dto/fav/create-fav';
// import { UpdateFavDto } from '../dto/fav/update-fav';

@Controller('custom/fav')
export class FavController {
  constructor(private readonly favService: FavService) {}

  @Post()
  create(@Body() createFavDto: CreateFavDto, @Req() req) {
    return this.favService.create(req.user.userId, createFavDto.productId);
  }

  @Get()
  findAll(@Req() req, @Query() pageDto: { pageNo: number; pageSize: number }) {
    console.log(req.user.userId, pageDto)
    return this.favService.findAll(req.user.userId, pageDto);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.favService.findOne(+id);
  }

  // @Patch(':id')
  // update(@Param('id') id: number, @Body() updateFavDto: UpdateFavDto) {
  //   return this.favService.update(+id, updateFavDto);
  // }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.favService.remove(+id);
  }
}
